import { get, post } from '@/utils/request';

// 定义接口类型
export interface LoginParams {
  username: string;
  password: string;
}

export interface UserInfo {
  id: number;
  username: string;
  realName: string;
  email: string;
  phone: string;
  avatar: string;
  roles: string[];
}

// 登录接口
export function login(data: LoginParams) {
  return post<{ token: string }>('/auth/login', data);
}

// 获取用户信息
export function getUserInfo() {
  return get<UserInfo>('/auth/info');
}

// 登出接口
export function logout() {
  return post('/auth/logout');
}

// 修改密码
export function changePassword(oldPassword: string, newPassword: string) {
  return post('/auth/change-password', {
    oldPassword,
    newPassword,
  });
}

// 获取用户列表
export function getUserList(params: any) {
  return get('/user/list', params);
}

// 添加用户
export function addUser(data: any) {
  return post('/user/add', data);
}

// 更新用户
export function updateUser(data: any) {
  return post('/user/update', data);
}

// 删除用户
export function deleteUser(id: number) {
  return post('/user/delete', { id });
} 